﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Vector
{
    public partial class Form1 : Form 
    {

        Class1 num = new Class1();
        

        

        public Form1()
        {
            InitializeComponent();
           



        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void OC_TextChanged(object sender, EventArgs e)
        {
            

        }

        private void m_TextChanged(object sender, EventArgs e)
        {

        }

        private void m_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar != 8))

            { e.Handled = true; }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            num.M = double.Parse(m.Text);
            num.N = double.Parse(n.Text);
            String[] s1 = e1.Text.Split(';');
            num.X1 = double.Parse(s1[0]);
            num.Y1 = double.Parse(s1[1]);
            String[] s2 = e2.Text.Split(';');
            num.X2 = double.Parse(s2[0]);
            num.Y2 = double.Parse(s2[1]);
            // AB=OB-OA ---OC=OA+AC=OA+(1/M)AB
            double X3 = num.X2 - num.X1;
            double Y3 = num.Y2 - num.Y1;
            double OCx = num.X1 + (1 / num.M) * X3;
            double OCy = num.Y1 + (1 / num.M) * Y3;
            VectorOC.Text = OCx.ToString() + "," + OCy.ToString();
            //OD=OA+(1/n)AB
            double ODx = num.X1 + (1 / num.N) * X3;
            double ODy = num.Y1 + (1 / num.N) * Y3;
            VectorOD.Text = ODx.ToString() + "," + ODy.ToString();

        }

        private void Form1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar != 8) && e.KeyChar != '.' && e.KeyChar!='-')

            { e.Handled = true; }
        }

        private void n_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar != 8) )

            { e.Handled = true; }
        }

        private void e1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8 && e.KeyChar != (char)('.') && e.KeyChar != 59)
            {
                e.Handled = true;
            }
            
        }

        private void e1_TextChanged(object sender, EventArgs e)
        {

        }

        private void e2_TextChanged(object sender, EventArgs e)
        {

        }

        private void e2_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8 && e.KeyChar != (char)('.') && e.KeyChar != 59)
            {
                e.Handled = true;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }
    }
}
